package structure;

import utilities.rle2dUtilities;

public class VSeries extends Area implements AreaInf {
	private int length;
	
	public VSeries (int x, int y, int len, int color,int byteSize) {
		this.setLength(len);
		super.setX(x);
		super.setY(y);
		super.setColor(color);
		super.setKind(rle2dUtilities.VSERIES);
		super.setByteSize(byteSize);
		this.evalPriority();
	}

	@Override
	public void evalPriority() {
		setPriority(length);
		
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	@Override
	public byte[] getBinary() {
		byte[] binary = new byte [2*super.getByteSize()+2];
		if(super.getByteSize()>1){
			//X
			binary[0] = (byte)getX();
			binary[1] = (byte)(getX() >> 8);
			//Y
			binary[2] = (byte)getY();
			binary[3] = (byte)(getY() >> 8);
			//LEN
			binary[4] = (byte)getLength();
			//COLOR
			binary[5] = (byte)getColor();
		}
		else {
			//X
			binary[0] = (byte)getX();
			//Y
			binary[1] = (byte)getY();
			//LEN
			binary[2] = (byte)getLength();
			//COLOR
			binary[3] = (byte)getColor();
		}
		return binary;
	}
	
}
